package cn.edu.hpu.action;




import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;

import cn.edu.hpu.pojo.Dealtype;
import cn.edu.hpu.service.DealtypeService;
import cn.edu.hpu.util.DateUtil;
import cn.edu.hpu.util.UUIDUtil;

import com.opensymphony.xwork2.ActionSupport;

public class DealtypeAction extends ActionSupport{
	private static final long serialVersionUID = 1L;
	private DealtypeService dealtypeService;
	private List<Dealtype> dealtypeList;
	private String id;
	private Dealtype dealtype;
	
	
	
	public String execute(){
		dealtypeList = dealtypeService.findAll();
		return "success";
	}
	
	public String save(){
		Dealtype dt = new Dealtype();
		
		dt.setId(UUIDUtil.getUUID());
		dt.setColor(dealtype.getColor());
		dt.setCreatetime(DateUtil.getTime());
		dt.setType(dealtype.getType());
		
		dealtypeService.save(dt);
		return "success";
	}
	public String update(){
		Dealtype dt = new Dealtype();
		
		dt.setId(dealtype.getId());
		dt.setColor(dealtype.getColor());
		dt.setCreatetime(DateUtil.getTime());
		dt.setType(dealtype.getType());
		
		dealtypeService.update(dt);
		return "success";
	}
	public String del(){
		System.out.println(id);
		dealtypeService.delete(id);
		
		return "success";
	}
	public String add(){
		return "success";
	}
	public String back(){
		return "success";
	}
	public String edit(){
		dealtype = dealtypeService.findADealtype(id);
		
		return "success";
	}
	// set get 
	public DealtypeService getDealtypeService() {
		return dealtypeService;
	}

	@Autowired
	public void setDealtypeService(DealtypeService dealtypeService) {
		this.dealtypeService = dealtypeService;
	}

	public List<Dealtype> getDealtypeList() {
		return dealtypeList;
	}

	public void setDealtypeList(List<Dealtype> dealtypeList) {
		this.dealtypeList = dealtypeList;
	}

	public String getId() {
		return id;
	}

	public void setId(String id) {
		this.id = id;
	}

	public Dealtype getDealtype() {
		return dealtype;
	}

	public void setDealtype(Dealtype dealtype) {
		this.dealtype = dealtype;
	}
	
	
	
}
